<div class="content-top">
    <div class="row">
        <div class="col-xs-6 slider">
            <article id="slider" class="banner-rotator" style="display:none">
                <ul class="br-slides">
                <?php $color = array('238, 238, 238', '0, 102, 255', '153, 102, 255'); ?>
                <?php foreach ($sliders as $key => $data): ?>
                    <li data-link="<?php echo Yii::app()->createUrl('/Events/default/view', array('category'=>$data->category->url, 'url'=>$data->url)); ?>">
                        <img src="<?php echo IMAGES_URL . 'events/slides/' . date('Ymd', strtotime($data->posteddate)) . '/' . $data->image; ?>" alt="<?php echo $data->title; ?>" />
                        <div class="tt-html"><?php echo $data->title; ?></div>
                        <div style="top:15px; left:25px; width: auto; height:auto; padding:5px; background-color: rgba(<?php echo $color[array_rand($color)]; ?>, 0.8);">
                            <span style="font-size:16px;font-weight: bold"><?php echo $data->category->title; ?></span>
                        </div>
                        <div style="top:50px; left:25px; width: auto; height:auto; padding:5px; background-color: rgba(0, 0, 0, 0.8);max-width: 460px;">
                            <span style="font-size:14px;"><?php echo $data->title; ?></span>
                        </div>
                    </li>
                <?php endforeach; ?>
                </ul>
            </article>
        </div>
        <div class="col-xs-6">
            <article id="event-hot">
            	<div class="row">
            	<?php foreach ($topevents as $key => $data): ?>
            	<div class="col-xs-6">
                    <div class="event-hot">
                        <div class="event-block">
                            <div class="event-content">
                                <h3><?php echo CHtml::link($data->title, array('/Events/default/view', 'category'=>$data->category->url, 'url'=>$data->url)); ?></h3>
                                <span class="meta">
                                    <span class="glyphicon glyphicon-time"></span> <?php echo ucwords(strftime('%H:%M - %A, ngày %d-%m-%Y', strtotime($data->startdate))); ?>
                                </span>
                            </div>
                            <div class="event-image">
                                <a href="<?php echo Yii::app()->createUrl('/Events/default/view', array('category'=>$data->category->url, 'url'=>$data->url)); ?>" class="hover-effect">
                                    <span class="cover">
                                        <span class="glyphicon glyphicon-link"></span>
                                        <img src="<?php echo IMAGES_URL . 'events/thumbs/' , date('Ymd', strtotime($data->posteddate)), '/', $data->image; ?>" alt="<?php echo $data->title; ?>" height="135" />
                                    </span>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
				<?php endforeach; ?>
            	</div>
            </article>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-xs-2 col-left">
    	<!-- Docs Categories -->
        <article class="event-categories">
        	<h3>Danh mục</h3>
            <nav class="nav-categories">
            <?php $this->widget('zii.widgets.CMenu', array(
				'items'=>$categories,
				'submenuHtmlOptions'=>array('class'=>'nav-sub'),
			)); ?>
            </nav>
        </article>
    	<!-- Docs Advance Search -->
        <?php $this->widget('Search'); ?>
        
        <aside class="box box-border">
        	<h3>Hỗ trợ</h3>
            <ul>
            	<li class="support"><i class="icon-phone"></i> <span>0969.836.599</span></li>
                <li class="support"><i class="icon-yahoo"></i> <a href="ymsgr:sendim?hoanghanktqd" title="Trợ giúp qua Yahoo: hoanghanktqd">hoanghanktqd</a></li>
                <li class="support"><i class="icon-skype"></i> <a href="skype:hoanghandnd?chat" title="Trợ giúp qua Skype: hoanghandnd">hoanghandnd</a></li>
            </ul>
            <p class="text-center">Cần hỗ trợ xin vui lòng liên hệ với chúng tôi!</p>
        </aside>
    </div>
    <div class="col-xs-7 col-middle">
    	<div class="event-header">
        	<div class="row">
                <div class="col-xs-6">
                    <h1>Sự kiện mới</h1>
                </div>
                <div class="col-xs-6">
                    <ul class="nav nav-tabs navbar-right">
                        <li class="active"><a href="javascript:void(0)">Tất cả</a></li>
                        <li><?php echo CHtml::link('Miễn phí', array('/Events/categories/freeEvent')); ?></li>
                        <li><?php echo CHtml::link('Sự kiện HOT', array('/Events/categories/hotEvent')); ?></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="event-list">
            <?php foreach ($model as $data):
                $this->renderPartial('application.modules.Events.views.default._view', array('data'=>$data));
            endforeach; ?>
        </div>
        <div class="event-load">
            <input type="hidden" name="counterEvent" id="counterEvent" value="1" />
            <?php echo CHtml::ajaxLink('Xem thêm các sự kiện khác',
                Yii::app()->createUrl('/Home/request/getEvent'),
                array(
                    'type' => 'POST',
                    'beforeSend' => 'function( request )
                    {
                        $(".view-more-event").before("<a class=\'btn btn-success span12 text-center loading-event\'><img src=\'' . Yii::app()->theme->baseUrl . '/images/ajax_loader.gif' . '\' alt=\'Loading more events\' /></a>").hide();
                    }',
                    'dataType' => 'json',
                    'success' => 'function( data )
                    {
                        if (data.status == "success")
                        {
							var scrollDiv = 0;
                            $.each(data.data, function(index,value){
								if (scrollDiv == 0)
									scrollDiv = value.id;
                                $(".event-list").append(value.content);
                            });
                            $("#counterEvent").val(parseInt($("#counterEvent").val()) + 1);
                            $(".loading-event").remove();
                            $(".view-more-event").show();
							$("html, body").animate({
								scrollTop: $("#event-"+scrollDiv).offset().top
							}, 2000);
                        }
                        else if (data.status == "limited") {
                            $(".loading-event").remove();
                            $(".view-more-event").show();
                            $(".view-more-event").html("Không còn sự kiện nào nữa!");
                            $(".view-more-event").attr("id", "");
                            $(".view-more-event").attr("href", "javascript:void(0)");
                        }
                    }',
                    'data' => 'js:{
                        "counterEvent" : $("#counterEvent").val(),
                    }'
                ),
                array(
                    'href' => Yii::app()->createUrl('/Home/default/index'),
                    'title'=>'View more events',
                    'class'=>'view-more-event btn btn-success span12 text-center',
                )); ?>
        </div>
    </div>
    <div class="col-xs-3 col-right">
        <aside class="box bg-grey text-center">
        	<p>Hãy cùng chia sẻ sự kiện trên<br>
                <strong><?php echo CHtml::link('NEXTTOPEVENT.COM', array('/Home/default/index'), array('title'=>'Mạng sự kiện NextTopEvent')); ?></strong>
                <br />
                <?php if (Yii::app()->user->isGuest) {
					echo CHtml::link('Đăng sự kiện <span class="glyphicon glyphicon-circle-arrow-right"></span>', array('/Users/default/login'), array('title'=>'Đăng nhập để đăng sự kiện tại NextTopEvent', 'class'=>'btn btn-create btn-login'));
				}
                else {
                	echo CHtml::link('Đăng sự kiện <span class="glyphicon glyphicon-circle-arrow-right"></span>', array('/Events/default/create'), array('title'=>'Đăng sự kiện tại NextTopEvent', 'class'=>'btn btn-create'));
                } ?>
                <br />
                <span>Đăng sự kiện <strong class="txt-upper">Miễn phí</strong></span>
            </p>
        </aside>
        
        <aside id="calendar"></aside>
        
        <aside class="widget box bg-grey">
        	<h3>Sự kiện được quan tâm</h3>
            <div class="event-small">
            <?php foreach ($homepage as $data): ?>
            	<div class="event-item">
                    <div class="event-image">
                        <a href="<?php echo Yii::app()->createurl('/Events/default/view', array('category'=>$data->category->url, 'url'=>$data->url)); ?>" title="<?php echo $data->title; ?>">
                            <img src="<?php echo IMAGES_URL . 'events/thumbs/' , date('Ymd', strtotime($data->posteddate)), '/', $data->image; ?>" alt="<?php echo $data->title; ?>" />
                        </a>
                    </div>
                    <div class="event-content">
                        <?php echo CHtml::link($data->title, array('/Events/default/view', 'category'=>$data->category->url, 'url'=>$data->url), array('title'=>$data->title)); ?>
                    </div>
                </div>
            <?php endforeach; ?>
            </div>
        </aside>
        
        <aside class="widget">
        	<h3 class="box box-border">Tin tức cập nhật</h3>
            <div class="box-border event-small">
            <?php foreach ($news as $data): ?>
            	<div class="event-item">
                    <div class="event-image">
                        <a href="<?php echo Yii::app()->createurl('/Home/news/view', array('slug'=>$data->slug)); ?>" title="<?php echo $data->title; ?>">
                            <img src="<?php echo IMAGES_URL . 'news/' , date('Ymd', strtotime($data->posteddate)), '/', $data->image; ?>" alt="<?php echo $data->title; ?>" />
                        </a>
                    </div>
                    <div class="event-content">
                        <?php echo CHtml::link($data->title, array('/Home/news/view', 'slug'=>$data->slug), array('title'=>$data->title)); ?>
                    </div>
                </div>
            <?php endforeach; ?>
            </div>
        </aside>
        
        <aside class="widget">
        	<h3 class="box box-border">Hoạt động đang diễn ra</h3>
            <div class="box-border">
                <div class="event-logs event-small" style="display: none;">
                <?php foreach ($logs as $data): ?>
                    <div class="event-item">
                        <div class="event-image">
                            <a href="<?php echo Yii::app()->createurl('/Users/Members/profile', array('id'=>$data->user_id)); ?>">
                                <img src="<?php echo IMAGES_URL . 'nte.jpg'; ?>" alt="<?php echo $data->message; ?>" />
                            </a>
                        </div>
                        <div class="event-content">
                            <?php echo CHtml::link($data->user->username, array('/Users/Members/profile', 'id'=>$data->user_id), array('title'=>$data->user->username)) . $data->message; ?>
                        </div>
                    </div>
                <?php endforeach; ?>
                </div>
            </div>
        </aside>
    </div>
</div>